<template>
  <div id="app">
    <ul>
      <li v-for="(item,index) in arr" :key="index">
        <span>{{item}}</span>
        <button @click="hDel(index)">删除</button>
      </li>
    </ul>
    <button @click="hAdd">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1, 5, 3],
    };
  },
  methods:{
    hAdd(){
      const random = Math.floor(Math.random() * 10)
      this.arr.push(random)
    },
    hDel(index){
       this.arr.splice(index,1)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    }
  }
}
</script>